<?php
/* 
 * Copyright (c) 2018-2021   All rights reserved.
 * 
 * 创建时间：2021-05-06 09:59
 *
 * 项目：upload  -  $  - sql.php
 *
 * 作者：liwei 
 */

!defined('INLEV') && exit('Access Denied LEV');

$charset = Lev::$app['db']['charset'];
$tableOptions = ' CHARACTER SET '.$charset.' ENGINE=MyISAM';
$tableNames = [
    '{{%levpays_trades}}'
];

//DROP TABLE IF EXISTS `pre_lev_modules`;
$sql = <<<EOF

DROP TABLE IF EXISTS `{{%levpays_trades}}`;
CREATE TABLE IF NOT EXISTS `{{%levpays_trades}}` (
  `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
  `paytypeid` smallint(6) UNSIGNED NOT NULL DEFAULT '0' COMMENT '支付类型ID',
  `paymethod` varchar(255) NOT NULL DEFAULT '' COMMENT '支付方式',
  `iden` varchar(220) NOT NULL DEFAULT '' COMMENT '模块标识',
  `goodsid` varchar(255) NOT NULL DEFAULT '0' COMMENT '模块标识对应的商品ID',
  `uid` bigint(20) NOT NULL DEFAULT '0' COMMENT '用户UID',
  `mchid` varchar(255) NOT NULL DEFAULT '' COMMENT '支付平台商户ID',
  `appid` varchar(255) NOT NULL DEFAULT '' COMMENT '支付应用ID',
  `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '支付应用ID对应的用户开放UID',
  `transaction_id` varchar(255) NOT NULL DEFAULT '' COMMENT '支付平台定单号',
  `name` varchar(255) NOT NULL DEFAULT '' COMMENT '商品名称',
  `descs` varchar(255) NOT NULL DEFAULT '' COMMENT '商品备注',
  `paymoney` varchar(255) NOT NULL DEFAULT '' COMMENT '支付金额',
  `paysource` varchar(255) NOT NULL DEFAULT '' COMMENT '支付来源',
  `ip` varchar(255) NOT NULL DEFAULT '' COMMENT 'IP',
  `goodsinfo` mediumtext NOT NULL COMMENT '商品详细信息',
  `settings` mediumtext NOT NULL COMMENT '通用设置',
  `tradestatus` tinyint(2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '定单状态',
  `status` tinyint(2) UNSIGNED NOT NULL DEFAULT '0' COMMENT '状态',
  `paytime` int(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '支付成功时间',
  `tradetime` int(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '下单时间',
  `uptime` int(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '更新时间',
  `addtime` int(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '添加时间',
  PRIMARY KEY (`id`),
  KEY `appid` (`appid`),
  KEY `uid` (`uid`),
  KEY `iden` (`iden`)
) $tableOptions;

EOF;

$sql .= \lev\base\Migrationv::getLevBaseTableCreateSql();

return [
    0 => $sql,
    1 => $tableNames
];
